﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Phones.Models;
using Phones.DataLayer;

namespace Phones.ViewModel
{
    public class TreeElementNodeViewModel : TreeViewItemViewModel
    {
        private TreeElement _treeElement;

        public TreeElementNodeViewModel(TreeViewItemViewModel parent, TreeElement treeElement)
            : base(parent, true)
        {
            _treeElement = treeElement;
        }

        public string Name
        {
            get { return _treeElement.Name; }
        }

        protected override void LoadChildren()
        {
            Children.Clear();
            var db = new DataLayer.TreeElementRepository();
            foreach (var child in _treeElement.Children)
            {
                Children.Add(new TreeElementNodeViewModel(this, child));
            }
        }
    }
}
